home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 August / Chip_1999-08_cd.bin / zkuste / MacOS / Files / His.sit / Hi's Universal Saver v.1.6.0 ∫ / Parts to Install / Menu Events 1.3.1 / Menu Events Sample Script < prev    next >
Text File  |  1996-02-24  |  2KB  |  37 lines

  1. set dialogResult to display dialog ┬
  2.     "Which application?" default answer "" buttons {"Cancel", "Choose╔", "OK"} default button "OK"
  3. if button returned of dialogResult is "OK" then
  4.     set targetApplication to application (text returned of dialogResult)
  5. else
  6.     set targetApplication to choose application
  7. end if
  8.  
  9. tell targetApplication
  10.     try
  11.         with timeout of 30 seconds -- some applications won't respond to Menu events
  12.             set menuListInfo to Query Menu List
  13.         end timeout
  14.     on error errorString number errorNumber
  15.         if errorNumber is -126 then -- dsMBarNFnd
  16.             error "Sorry, that program does not have a menu bar.  It may be background-only." number -126
  17.         else
  18.             error errorString number errorNumber
  19.         end if
  20.     end try
  21.     if (count of menuListInfo) is greater than 0 then
  22.         set menuListText to menu title of item 1 of menuListInfo
  23.         repeat with menuIndex from 2 to count of menuListInfo
  24.             set menuListText to menuListText & ", " & menu title of item menuIndex of menuListInfo
  25.         end repeat
  26.         tell me to display dialog "The menu titles are " & menuListText & "."
  27.     end if
  28.     set menuInfo to Query Menu menu title "File"
  29.     repeat with menuItemID from 1 to count of menuInfo
  30.         set menuItemInfo to item menuItemID of menuInfo
  31.         if menu item enabled of menuItemInfo then
  32.             tell me to display dialog "File menu item ╥" & (menu item text of menuItemInfo) & "╙ is enabled."
  33.         end if
  34.     end repeat
  35.     Select Menu Item menu title "File" menu item text "Quit" with option key -- Option-Quit
  36. end tell
  37. display dialog "The application has quit.  Goodbye!"